/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.DealFieldManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class AddDealField extends AbstractAction
/*    */ {
/* 25 */   private static Logger logger = Logger.getLogger(AddDealField.class
/* 26 */     .getName());
/*    */ 
/*    */   public AddDealField(AbstractHttpServlet servlet)
/*    */   {
/* 29 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 36 */     String field = Util.getURLParameter(request.getParameter("field"));
/* 37 */     int valueType = Util.getURLIntParameter(request
/* 38 */       .getParameter("valueType"));
/* 39 */     int fieldMandatory = Util.getURLIntParameter(request
/* 40 */       .getParameter("fieldMandatory"));
/* 41 */     String initValue = Util.getURLParameter(request
/* 42 */       .getParameter("initValue"));
/*    */ 
/* 44 */     User user = super.getLoginUser(request);
/*    */ 
/* 46 */     response.setContentType("text/html;charset=utf-8");
/* 47 */     PrintWriter out = response.getWriter();
/*    */ 
/* 49 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 51 */     DealFieldManager manager = new DealFieldManager();
/*    */     try {
/* 53 */       int id = manager.add(user.companyId, field, valueType, initValue, 
/* 54 */         fieldMandatory, user.userId);
/* 55 */       jsonObject.put("error", "0");
/* 56 */       jsonObject.put("fieldId", Integer.valueOf(id));
/*    */     } catch (DBException e) {
/* 58 */       logger.warn("add deal field failed", e);
/* 59 */       jsonObject.put("error", "1");
/*    */     } catch (SQLException e) {
/* 61 */       logger.warn("add deal field failed", e);
/* 62 */       jsonObject.put("error", "1");
/*    */     }
/*    */ 
/* 65 */     out.println(jsonObject);
/* 66 */     out.flush();
/* 67 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.AddDealField
 * JD-Core Version:    0.6.1
 */